In this article, we have mentioned all the important attributes associate with both <form> and <input> elements. Generally, the form attributes deal with the
<input>
element data types and their submission action. It is very important to know all the forms attributes because we need to mention some specific attribute for specific input types.
Form Attribute
<input form="">
it is an attribute of <input> element, and it specifies the parent form of the <input> element. The value of the form attribute must be equal to the id attribute value of <form>.
Preview
Username:
Update UserName:
Formaction
formaction
is the attribute of <input> element and it define the URL of the backend file which will process the input data when the user hits the submit button. if the <form action=""> element has an action attribute then
formaction
attribute of <input> will overwrite it.
Example
Preview
Formenctype
The
formenctype
attribute defines how will be the form data get encoded when the user click on the submit button. This attribute will only work when the form method is "post". We mention this attribute with submit and image type <input> element.
Example:
Output
Formmethod
The
formmethod
attribute define which HTTP method should be followed when the user clicks on the submit button. If the <form> element already has a method attribute when
formmethod
attribute of <input> element would overwrite it.
Example
Preview
Formtarget
f
ormtarget
is similar to the target attribute of <a> element. It specifies whether to open a new tab when the user clicks on the submit button or process the data on the same tab.
Example
Preview
Formnovalidate
Generally, the
type
attribute is also used to set a validate data type. But if the form submits button has a
formnovalidate
attribute then the form data will be submitted without validation check.
Example
Preview
Form Input Attribute
-
form
attibute is used to specify the parent form of the <input> element. -
formaction
attribute can overwrite the action attribute of <form>. -
formectype
specifies how should be the form data encoded. -
formenctype
only work with post method. -
formnovalidate
attribute can send the data without validation check.